<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache,must-revalidate">
    <title>密码管理-个人用户</title>
    <link type="text/css" rel="stylesheet" href="/css/regist.personal.css"/>
    <link type="text/css" rel="stylesheet" href="/css/passport.base.css"/>
    <script type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
</head>
<body>
<script type="text/javascript">
    function login() {
        location.href = "/user/login.html";
        return false
    }
    function regist() {
        location.href = "/user/register.html";
        return false
    }
    (function (a) {
        a.fn.Jdropdown = function (d, e) {
            if (!this.length) {
                return
            }
            if (typeof d == "function") {
                e = d;
                d = {}
            }
            var c = a.extend({event: "mouseover", current: "hover", delay: 0}, d || {});
            var b = (c.event == "mouseover") ? "mouseout" : "mouseleave";
            a.each(this, function () {
                var h = null, g = null, f = false;
                a(this).bind(c.event,
                    function () {
                        if (f) {
                            clearTimeout(g)
                        } else {
                            var j = a(this);
                            h = setTimeout(function () {
                                j.addClass(c.current);
                                f = true;
                                if (e) {
                                    e(j)
                                }
                            }, c.delay)
                        }
                    }).bind(b, function () {
                    if (f) {
                        var j = a(this);
                        g = setTimeout(function () {
                            j.removeClass(c.current);
                            f = false
                        }, c.delay)
                    } else {
                        clearTimeout(h)
                    }
                })
            })
        }
    })(jQuery);
    function addToFavorite() {
        var a = "http://www.jt.com/";
        var b = "京淘商城-网购上京淘，省钱又放心";
        if (document.all) {
            window.external.AddFavorite(a, b)
        } else if (window.sidebar) {
            window.sidebar.addPanel(b, a, "")
        } else {
            alert("对不起，您的浏览器不支持此操作!\n请您使用菜单栏或Ctrl+D收藏本站。")
        }
    }</script>
<!--shortcut start-->
<jsp:include page="../commons/shortcut.jsp" />
<!--shortcut end-->
<div class="w" id="logo">
    <div>
        <a href="http://www.jt.com/">
            <img src="/images/jt-logo.png" alt="京淘商城" width="170" height="60"/>
        </a>
    </div>
</div>

<div class="w" id="regist">
    <div class="mt">
        <ul class="tab">
            <li class="curr">个人用户</li>
            <li class="line hide"><a clstag="regist|keycount|personalreg|02" href="../reg/company">企业用户</a></li>
            <li class="fore hide"><a href="http://passport.en.jd.com/user/facade">International Customers</a></li>
        </ul>
    </div>
    <div class="mc">
        <form id="personRegForm" method="POST" onsubmit="return false;">
            <input type="hidden" name="regType" id="regType" value="person"/>
            <input type="hidden" name="uuid" id="uuid" value="${uuid}"/>
            <input type="hidden" name="verifymc" id="verifymc" value=""/>
            <input type="hidden" name="emailMg" id="emailMg"/>
            <input type="hidden" name="authcodeMg" id="authcodeMg"/>
            <input type="hidden" name="state" id="state" value=""/>

            <div class="form" onselectstart="return false;">
                <div class="item" id="select-regName">
                    <span class="label"><b class="ftx04">*</b>用户名：</span>

                    <div class="fl item-ifo">
                        <div class="o-intelligent-regName">
                            <input type="text" id="username" name="username" class="text" tabindex="1" autoComplete="off"
                                   onpaste="return false;"
                                   value=""
                                   onfocus="if(this.value=='') this.value='';this.style.color='#333'"
                                   onblur="if(this.value=='') {this.value='';this.style.color='#999999'}"/>
                            <i class="i-name"></i>
                            <ul id="intelligent-regName" class="hide"></ul>
                            <label id="regName_succeed" class="blank"></label>
                            <label id="regName_error" class="hide"></label>
                        </div>

                        <div class="intelligent-error hide" id="morePinDiv">
                            <h5>推荐您使用：</h5>

                            <div class="groom" id="morePinGroom"></div>
                        </div>
                        <input type="hidden" value="-1" id="hnschool" class="hide"/>
                        <input type="hidden" id="schoolid" name="schoolid" class="hide"/>
                        <input type="hidden" name="eBHtwyeixI" value="EyEFt"/>
                        <input type="hidden" id="hnseli" class="hide"/>

                    </div>
                </div>

                <div id="capslock"><i></i><s></s>键盘大写锁定已打开，请注意大小写</div>
                <div id="o-password">
                    <div class="item hide" id="oldPwdDiv">
                        <span class="label"><b class="ftx04">*</b>请输入旧密码：</span>
                        <div class="fl item-ifo">
                            <input type="password" id="oldPwd" name="oldPwd" class="text" tabindex="3"
                                   onpaste="return  false" autocomplete="off"/>
                            <i class="i-pass"></i>
                            <label id="oldPwd_succeed" class="blank"></label>
                            <label id="oldPwd_error"></label>
                        </div>
                    </div>
                    <div class="item">
                        <span class="label"><b class="ftx04">*</b>请设置新密码：</span>

                        <div class="fl item-ifo">
                            <input type="password" id="pwd" name="password" class="text" tabindex="2"
                                   style="ime-mode:disabled;"
                                   onpaste="return  false" autocomplete="off"/>
                            <i class="i-pass"></i>
                            <label id="pwd_succeed" class="blank"></label>
                            <label id="pwd_error"></label>
                            <span class="clr"></span>
                            <label class="hide" id="pwdstrength"><span class="fl">安全程度：</span><b></b></label>

                        </div>
                    </div>

                    <script type="text/javascript">
                        $('#pwd')[0].onkeypress = function (event) {
                            var e = event || window.event,
                                $tip =
                                    $('#capslock'),
                                kc = e.keyCode || e.which, // 按键的keyCode
                                isShift = e.shiftKey || (kc == 16 ) || false; // shift键是否按住
                            if (((kc >= 65 && kc <= 90) && !isShift) || ((kc >= 97 && kc <= 122) && isShift)) {
                                $tip.show();
                            }
                            else {
                                $tip.hide();
                            }
                        };
                    </script>

                    <div class="item">
                        <span class="label"><b class="ftx04">*</b>请确认新密码：</span>

                        <div class="fl item-ifo">
                            <input type="password" id="pwdRepeat" name="pwdRepeat" class="text" tabindex="3"
                                   onpaste="return  false" autocomplete="off"/>
                            <i class="i-pass"></i>
                            <label id="pwdRepeat_succeed" class="blank"></label>
                            <label id="pwdRepeat_error"></label>
                        </div>
                    </div>
                    <div class="item" id="dphone">
                        <span class="label"><b class="ftx04">*</b>验证手机：</span>

                        <div class="fl item-ifo">
                            <input type="text" id="phone" maxlength="11" name="phone" class="text" tabindex="4" onfocus="phoneFocus();" onKeyup="phoneKeyup1();" onblur="phoneBlur1();" autocomplete="off"/>
                            <i class="i-phone"></i>
                            <label id="phone_succeed" class="blank"></label>
                            <label id="phone_error"></label>
                        </div>
                    </div>

                    <div id="mobileCodeDiv" class="item hide" style="height: 62px;">
                        <span class="label"><b class="ftx04">*</b>短信验证码：</span>

                        <div class="fl item-ifo">
                            <input type="text" maxlength="6" autocomplete="off" tabindex="6" class="text text-1"
                                   name="mobileCode"
                                   style="ime-mode:disabled" id="mobileCode" onblur="mobileCodeBlur()"
                                   onfocus="mobileCodeFocus();">
                            <label class="blank invisible"></label>
                            <a class="btn" href="javascript:void(0);" onclick="sendmCode();" id="sendMobileCode">
                                <span id="dyMobileButton">获取短信验证码</span></a>
                            <span class="clr"></span>

                            <div class="msg-text" id="mobileCodeSucMessage"></div>
                            <label id="mobileCode_error" class="blank"></label>
                            <label id="mobileCode_succeed" class="blank invisible"></label>
                        </div>
                        <span class="clr"></span>
                    </div>

                </div>
                <div class="pwd-error" style="color: red;display: none">
                    <span class="label" style="color: red">错误提示: </span>
                    <span class="message"></span>
                </div>
                <div class="item">

                    <span class="label">&nbsp;</span>
                    <input type="button" class="btn-img btn-regist" id="registsubmit" value="确认修改" tabindex="8"
                            onclick="forgetPwd();"/>
                </div>

            </div>
            <span class="clr"></span>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        let flag = getUrlParam('flag');
        if (flag=="update"){
            //修改密码
            $("#select-regName").attr("class","item hide");
            $("#dphone").attr("class","item hide");
            $("#oldPwdDiv").attr("class","item");
            $("#registsubmit").attr("onclick",'').click( eval(updatePwd));
        }
    })
    //获取地址栏的参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        //返回参数值
        if (r!=null){
            return unescape(r[2]);
        }
        return null;
    }
    //修改密码
    function updatePwd(){
        debugger
        var flag = true;
        var oldPwd = $("#oldPwd").val();
        var pwd = $("#pwd").val();
        var pwdRepeat = $("#pwdRepeat").val();
        if (pwd == "") {
            $('#oldPwd').addClass('highlight2');
            $('#oldPwd_error').removeClass().addClass('error').html('请输入旧密码');
            $('#oldPwd_error').show();
            flag = false
        }
        if (pwd == "") {
            $('#pwd').addClass('highlight2');
            $('#pwd_error').removeClass().addClass('error').html('请输入新密码');
            $('#pwd_error').show();
            flag = false
        }
        if (pwdRepeat == "") {
            $('#pwdRepeat').addClass('highlight2');
            $('#pwdRepeat_error').removeClass().addClass('error').html('请确认新密码');
            $('#pwdRepeat_error').show();
            flag = false
        }
        if (flag) {
            $("#registsubmit").attr({
                "disabled" : "disabled"
            }).removeClass().addClass("btn-img btn-regist wait-btn");
            $.ajax({
                type : "POST",
                dataType : "json",
                url : "/user/updatePwd/2",
                data : $("#personRegForm").serialize(),
                contentType : "application/x-www-form-urlencoded; charset=utf-8",
                success : function(result) {
                    if(result.status == 200){  //返回的数据SysResult对象
                        // 注册成功，去登录页
                        showMessage('修改成功，请登录！');
                        verc();
                        $("#registsubmit").removeAttr("disabled").removeClass()
                            .addClass("btn-img btn-regist");
                        isSubmit = false;
                        setTimeout("window.location.href='/user/login'","2000");
                    }else{
                        showMessage('修改失败,请联系管理员!');
                    }
                },
                error : function(error) {
                    $(".pwd-error").show()
                    $(".pwd-error .message").text("亲爱的用户请不要频繁点击, 请稍后重试...")
                }
            });
        } else {
            $("#registsubmit").removeAttr("disabled").removeClass().addClass(
                "btn-img btn-regist");
            isSubmit = false;
        }
    }
    //忘记密码
    function forgetPwd(){
        debugger
        var flag = true;
        var username = $("#username").val();
        var pwd = $("#pwd").val();
        var pwdRepeat = $("#pwdRepeat").val();
        var mobile = $("#phone").val();
        var mobileCode = $("#mobileCode").val();
        if (username == "") {
            $('#regName').addClass('highlight2');
            $('#regName_error').removeClass().addClass('error').html('请输入用户名');
            $('#regName_error').show();
            flag = false
        }
        if (pwd == "") {
            $('#pwd').addClass('highlight2');
            $('#pwd_error').removeClass().addClass('error').html('请输入新密码');
            $('#pwd_error').show();
            flag = false
        }
        if (pwdRepeat == "") {
            $('#pwdRepeat').addClass('highlight2');
            $('#pwdRepeat_error').removeClass().addClass('error').html('请确认新密码');
            $('#pwdRepeat_error').show();
            flag = false
        }
        if (mobile == "") {
            $('#phone').addClass('highlight2');
            $("#phone_error").html("请输入手机号码");
            $("#phone_error").removeClass().addClass("error");
            $("#phone_error").show();
            flag = false
        }
        if (mobileCode == "") {
            $('#mobileCode').addClass('highlight2');
            $('#mobileCode_error').removeClass().addClass('error').html('请输入短信验证码');
            $('#mobileCode_error').show();
            flag = false
        }
        if (flag) {
            $("#registsubmit").attr({
                "disabled" : "disabled"
            }).removeClass().addClass("btn-img btn-regist wait-btn");
            $.ajax({
                type : "POST",
                dataType : "json",
                url : "/user/updatePwd/1",
                data : $("#personRegForm").serialize(),
                contentType : "application/x-www-form-urlencoded; charset=utf-8",
                success : function(result) {
                    if(result.status == 200){  //返回的数据SysResult对象
                        // 注册成功，去登录页
                        showMessage('修改成功，请登录！');
                        verc();
                        $("#registsubmit").removeAttr("disabled").removeClass()
                            .addClass("btn-img btn-regist");
                        isSubmit = false;
                        setTimeout("window.location.href='/user/login'","2000");
                    }else{
                        showMessage('修改失败,请联系管理员!');
                    }
                },
                error : function(error) {
                    $(".pwd-error").show()
                    $(".pwd-error .message").text("请不要频繁点击, 请稍后重试...")
                }
            });
        } else {
            $("#registsubmit").removeAttr("disabled").removeClass().addClass(
                "btn-img btn-regist");
            isSubmit = false;
        }
    }
</script>

<script type="text/javascript">
    function hello() {
        var helloUrl = "http://passport.jd.com/call/getHelloJson?m=ls";
        jQuery.ajax({url: helloUrl, dataType: "jsonp", scriptCharset: "gb2312", success: function (a) {
                if (a && a.info) {
                    $("#loginbar").html(a.info);
                }
                if (a && a.sso) {
                    $.each(a.sso, function () {
                        $.getJSON(this)
                    })
                }
            }});
    }
    (function ($) {
        $("#shortcut-2013 .menu").Jdropdown({delay: 50});
        //hello();
    })(jQuery);</script>
<div class="w">
    <!-- links start -->
    <jsp:include page="../commons/footer-links.jsp"></jsp:include>
    <!-- links end -->
</div>
<script type="text/javascript" src="/js/register/jd.lib.js"></script>
<script type="text/javascript" src="/js/register/jdThickBox.js"></script>
<script type="text/javascript" src="/js/register/jdValidate.js"></script>
<script type="text/javascript" src="/js/register/jdValidate.emReg.js"></script>
<script type="text/javascript" src="/js/register/jdValidate.regSuccess.js"></script>
<script type="text/javascript" src="/js/jt.js" charset="utf-8"></script>

</body>
</html>
